package com.gfxy.educational.controller;

import com.gfxy.common.portal.entity.SysOrganization;
import com.gfxy.common.portal.service.OrganizationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author: lijixin 2019-06-04
 */
@Controller
@RequestMapping("/studentRegister")
public class StudentRegisterController {

    private static final Logger logger = LoggerFactory.getLogger(StudentRegisterController.class);

    @Autowired
    private OrganizationService organizationService;

    @RequestMapping(value = "/index.action", method = RequestMethod.GET)
    public String studentRegister(HttpServletRequest request, HttpServletResponse response){
        String id = request.getParameter("id");
        if(id==null || id.isEmpty()){
            return "error/403";
        } else {
            request.setAttribute("wechatId",id);
            return "educational/appraise/studentRegister";
        }
    }

    @RequestMapping(value="/getOrganization",method = RequestMethod.GET)
    public @ResponseBody List<SysOrganization> getOrganization(){
        logger.info("开始获取所有分院信息");
        return organizationService.getOrganizationByType("1");
    }

}
